import 'package:flutter/material.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import '../models/hire_rent_model.dart';

class HireRentInfoItem extends StatelessWidget {
  final TmcContractOrderDetails? itemModel;
  final bool showSpeck;
  const HireRentInfoItem({
    super.key,
    this.itemModel,
    this.showSpeck = true,
  });

  /*
  * 获取状态
  * */
  String getStatus() {
    String state = "其他错误";
    switch (itemModel?.tmcDoorsDoorState) {
      case 7:
        state = "空闲中";
        break;
      case 6:
        state = "待取件";
        break;
      case 31:
        state = "投递失败";
        break;
      case 32:
        state = "取件失败";
        break;
      case 33:
        state = "撤回失败";
        break;
      case 34:
        state = "远程失败";
        break;
      default:
        state = "其他错误";
    }
    return state;
  }

  /*
   * 获取类型
   * */
  String getType() {
    String type = "小";
    switch (itemModel?.tmcDoorsDoorType) {
      case 1:
        type = "大";
        break;

      case 2:
        type = "中";
        break;

      default:
        type = "小";
    }
    return type;
  }

  /*
  * 获取颜色
  * */
  Color getColors() {
    if (itemModel == null) {
      return MGColors.text1Color;
    }
    if (itemModel?.tmcDoorsDoorState == 7 || itemModel?.tmcDoorsDoorState == 6) {
      return MGColors.themeColor;
    }
    return MGColors.redColor;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: MGColors.whileColor,
      padding: EdgeInsets.only(top: 20, bottom: 20),
      child: Flex(
        direction: Axis.horizontal,
        children: [
          Expanded(
              child: Text(
            (itemModel != null) ? (itemModel!.tmcDoorsDisplayAlias ?? "") : "格口",
            style: TextStyle(
              color: MGColors.text1Color,
              fontSize: MGFont.textFont1,
            ),
            textAlign: TextAlign.center,
          )),
          Container(
            width: showSpeck ? 1 : 0,
            height: 20,
            color: MGColors.splitColor,
          ),
          Expanded(
              child: Text(
            (itemModel != null) ? getType() : "类型",
            style: TextStyle(
              color: MGColors.text1Color,
              fontSize: MGFont.textFont1,
            ),
            textAlign: TextAlign.center,
          )),
          Container(
            width: showSpeck ? 1 : 0,
            height: 20,
            color: MGColors.splitColor,
          ),
          Expanded(
              child: Text(
            (itemModel != null) ? getStatus() : "状态",
            style: TextStyle(
              color: getColors(),
              fontSize: MGFont.textFont1,
            ),
            textAlign: TextAlign.center,
          )),
        ],
      ),
    );
  }
}
